<template>
<div class="wrappers">
    <header>
        <p>新增送货地址</p>
    </header>
</div>
    <ul class="form-box">
        <li class="liTile">
            <div class="title1">联系人：</div>
            <div class="content">
                <input type="text" placeholder="联系人姓名" v-model="contactName" class="inputTile"/>
            </div>
        </li>
        <li class="liTile">
            <div class="title1">性别：</div>
         
            <div class="content">
                <input type="radio"name="sex"style="width: 6vw; height: 3.2vw;"  v-model="contactSex" value="1" />男
                <input type="radio" name="sex" style="width: 6vw; height: 3.2vw;" v-model="contactSex" value="0"/>女

            </div>
        </li>
        <li class="liTile">
            <div class="title1">电话：</div>
            <div class="content">
                <input type="tel" placeholder="电话" v-model="contactTel" class="inputTile">
            </div>
        </li>
        <li class="liTile">
            <div class="title1">收货地址：</div>
            <div class="content">
                <input type="text" placeholder="收货地址" v-model="address" class="inputTile"/>

            </div>

        </li>
    </ul>
    <div class="button-add">
        <button @click="addUserAddress">保存</button>
    </div>

<Footer></Footer>
</template>
<style>
.wrappers{
    width: 100%;
    height: 100px;
    font-size: 50px;
    background-color: #0097ff;
    color: white;
    text-align: center;
}
 .liTile{
display: flex;
margin-top: 20px;
width: 100%;
 }
 .content{
    width: 80%;
 }
.title1{
   
    font-size: 30px;
    text-align: left;
}
.inputTile{
    width: 500px;
    height: 40px;
    font-size: 25px;
}
input::-webkit-input-placeholder {
/* placeholder颜色 */
color: #aab2bd;
/* placeholder字体大小 */
font-size: 25px;
}
</style>
<script>
export default{
name:"addUserAddress",
data(){
    return{
        contactName:"",
        contactSex:"",
        contactTel:"",
        address:"",
        businessId:"",
        user:{}

    };
},
created(){
  businessId: this.$route.query.businessId,
  this.user = this.$getSessionStorage('user');
},
methods:{
    addUserAddress(){
        if(this.contactName ==''){
            alert('联系人姓名不能为空');
            return;
        }
        if(this.contactSex ==''){
            alert('联系人性别不能为空');
            return;
        }
        if(this.contactTel==''){
            alert('联系人电话不能为空');
            return;
        }
        if(this.address ==''){
            alert('联系人地址不能为空');
            return;
        }
        this.$axios.post('DeliveryAddressController/saveDeliveryAddress',this.$qs.stringify(
            {
                contactName:this.contactName,
                contactSex:this.contactSex,
                contactTel:this.contactTel,
                address:this.address,
                userId:this.user.userId
            }
        )).then(response =>{
            if(response.data>0){
                this.$router.push({
                    path:'/userAddress',
                    query:{
                        businessId:this.businessId
                    }
                })
            }        
        }).catch(error =>{
            console.error(error);
            
        })
    }
}
}
</script>